import { Notification, Message, Loading } from 'element-ui'
import { get, defaultsDeep, cloneDeep } from 'lodash'
import { login, pending, getUserInfo } from '@/api/login'

export interface State { }

const state: State = {
  loginUser: {
    authoritys: []
  },
  isAdmin: false,
}

const getters = {}

const mutations = {
  SET_LOGIN_USER(state: any, payload: any) {
    state.loginUser = payload
    if (state.loginUser.roles.indexOf('系统管理员') != -1) {
      state.isAdmin = true
    } else {
      state.isAdmin = false
    }
    sessionStorage.setItem('token', state.loginUser.token);
    sessionStorage.setItem('loginTimes', '2');
  }
}

const actions = {}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}
